import os
import zipfile

def unzip_resources():
    current_dir = os.getcwd()
    res_dir = os.path.join(current_dir, 'res')

    for root, dirs, files in os.walk(res_dir):
        for file in files:
            if file.endswith('.zip'):
                zip_path = os.path.join(root, file)
                extract_dir = os.path.dirname(zip_path)
                try:
                    with zipfile.ZipFile(zip_path, 'r') as zip_ref:
                        zip_ref.extractall(extract_dir)
                    print(f'已解压: {zip_path}')
                except Exception as e:
                    print(f'解压失败: {zip_path}')
                    print(f'错误信息: {str(e)}')


if __name__ == '__main__':
    # 先解压所有zip文件
    print('开始解压文件...')
    unzip_resources()
    print('解压完成！')
    